<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>cookie.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>content_addtop_new.js"></script>
<h3 style="padding-left: 20px;padding-top: 10px">
	<?=$info['subject']?>——
	<?php if ($info['subject_type'] == 1){?>人才
	<?php }elseif($info['subject_type'] == 2){?>赛事
	<?php }elseif($info['subject_type'] == 3){?>活动
	<?php }elseif($info['subject_type'] == 4){?>机构
	<?php }elseif($info['subject_type'] == 5){?>课程
	<?php }elseif($info['subject_type'] == 6){?>通用<?php }?>
	<a href="./index.php?m=vote&c=vote&a=init" style="font-size:14px;color: #0000FF"><em>返回上一级</em></a>
</h3>

<div class="pad-lr-10">

	<form name="searchform" action="" method="get">
		<input type="hidden" value="<?php echo ROUTE_M;?>" name="m">
		<input type="hidden" value="<?php echo ROUTE_C;?>" name="c">
		<input type="hidden" value="<?php echo ROUTE_A;?>" name="a">
		<input type="hidden" value="<?=$subjectid?>" name="subjectid">
		<input type="hidden" value="<?php echo $_SEEEION['pc_hash'];?>" name="pc_hash">

		<table width="100%" cellspacing="0" class="search-form">
			<tbody>
			<tr>
				<td>
					<?php if($info['subject_type'] != 6){?>
					<button type="button" style="float:right;margin-right:20px;margin-top:10px;" onclick="ajaxoption(<?=$subjectid?>)" ><em>一键替换</em></button>
					<?php }?>
					<button type="button" style="float:right;margin-right:20px;margin-top:10px;" onclick="showSelect()" ><em><?php echo L('select_option_'.$info['subject_type']);?></em></button>
					<span style="clear: both"></span>
					<script>
						function  showSelect(){
							window.top.art.dialog({
									id: 'select',
									iframe: '?m=vote&c=vote&a=bindTalent&subjectid=<?=$subjectid?>&subject_type=<?=$info["subject_type"]?>',
									title: '<?php echo L("select_option_".$info["subject_type"]);?>',
									width: '900',
									height: '500',
									lock: true
								},
								function() {
									var d = window.top.art.dialog({
										id: 'select'
									}).data.iframe;
									var relation = d.document.getElementById('relation');

									$.ajax({
										type:"get",
										url:"?m=vote&c=vote&a=bindOptionAjax&subjectid=<?=$subjectid?>&relation="+relation.value+"&pc_hash=<?php echo $_SESSION['pc_hash'];?>&subject_type=<?=$info['subject_type']?>",
										dataType: "json",
										success:function(data){
											if(data['status']){
												window.top.art.dialog({
													id: 'select'
												}).close()
												window.location.reload();
											}else{
												alert(data['msg']);
												return false;
											}
										}
									})
									return false;
								},
								function() {
									window.top.art.dialog({
										id: 'select'
									}).close()
								});
						}
					</script>

					<div class="explain-col">
						<?php echo L('vote_option')?>：
						<input name="name" type="text" value="<?php if(isset($_GET['name'])) {echo $_GET['name'];}?>"
							   class="input-text" />
						<input type="submit" name="search"  class="button" value="<?php echo L('search')?>" />
					</div>


				</td>
			</tr>
			</tbody>
		</table>
	</form>

	<form name="myform" action="?m=vote&c=vote&a=vote_del" method="post"
		onsubmit="return confirm('<?php echo L('confirms')?>')">
		<div class="table-list">
			<table width="100%" cellspacing="0">
				<thead>
					<tr>
						<th align="center" width="20"><input type="checkbox" value=""
							id="check_box" onclick="selectall('id[]');"></th>
						<th align="center" width="30"><?php echo L('listorder');?></th>
						<th align="center" width="30">ID</th>
						<th align="center" width="100"><?php echo L('vote_option')?></th>
						<th align="center" width="80"><?php echo L('vote_images')?></th>
						<th align="center" width="80">初始票数</th>
						<th align="center" width="80">真实票数</th>
						<th align="center" width="80">初始金额</th>
						<th align="center" width="80">真实金额</th>
						<th align="center" width="250"><?php echo L('operations_manage')?></th>
					</tr>
				</thead>
				<tbody>
<?php
if (!empty($optionsList)) {
foreach ($optionsList as $k => $v) {
    ?>
    <tr>
		<td align="center"><input type="checkbox"
			value="<?php echo $v['id']?>" name="id[]"></td>
		<td align='center'><input name='listorders[<?php echo $v['id'];?>]' type='text' size='3' value='<?php echo $v['listorder'];?>' class='input-text-c'></td>
		<td align="center"><?php echo $v['id']?></td>
		<td align="center"><?php echo $v['option']?></td>
		<td align="center"><?php if(!empty($v['image'])){echo '<a href="javascript:image_priview(\''.$v['image'].'\');"><img src="'.$v['image'].'" height="60px"></a>';}else{echo '<font color="red">（未设置）</font>';}?></td>
		<td align="center"><?php echo $v['origin_num']?$v['origin_num']:'<font color="red">(未设置)</font>';?></td>
		<td align="center"><?php echo $v['real_num']?$v['real_num']:'<font color="red">(未设置)</font>';?></td>
		<td align="center"><?php echo $v['money']?$v['money']:'<font color="red">(未设置)</font>';?></td>
		<td align="center"><?php echo $v['real_money']?$v['real_money']:'<font color="red">(未设置)</font>';?></td>
		<td align="center">
			<a href="?m=vote&c=vote&a=optionmoneylist&id=<?php echo $v['id']?>" >金额明细</a> | 
			<a href="###"
			onclick="edits(<?php echo $v['id']?>, '<?php echo new_addslashes($v['option'])?>')"
			title="<?php echo L('edit')?>">修改金额</a> | 
			<a href="###"
			onclick="edit(<?php echo $v['id']?>, '<?php echo new_addslashes($v['option'])?>')"
			title="<?php echo L('edit')?>"><?php echo L('edit')?></a> | 
			<a href="?m=vote&c=vote&a=vote_del&id=<?php echo $v['id']?>"
			onClick="return confirm('<?php echo L('confirms')?>')"><?php echo L('deleteoption')?></a><!--  | 
			<a href="?m=vote&c=vote&a=order_support&id=<?php echo $v['id']?>"><?php echo L('order_support')?></a> -->
		</td>
	</tr>
<?php
}
} else {
	echo "<tr><td colspan='10' style='color:red;font-size:18px;text-align:center;'><span>暂无数据！</span></td></tr>";
}
?>
</tbody>
			</table>

			<div class="btn">
				<label for="check_box">
					<a href="#"
					onClick="javascript:$('input[type=checkbox]').attr('checked', true)"><?php echo L('select_all')?></a>/<a
					href="#"
					onClick="javascript:$('input[type=checkbox]').attr('checked', false)"><?php echo L('cancel')?></a></label>
					<input type="button" class="button" value="<?php echo L('listorder');?>" onclick="myform.action='?m=vote&c=vote&a=listorder&dosubmit=1&steps=<?php echo $steps;?>';myform.submit();"/>
				<input type="submit" class="button" name="dosubmit"
					value="<?php echo L('deleteoption')?>" />
			</div>

			<div id="pages"><?php echo $pages?></div>
		</div>
	</form>
</div>
<script type="text/javascript">
	function ajaxoption(subjectid) {
		$.ajax({
			type:"get",
			url:"?m=vote&c=vote&a=editImageOption&subjectid="+subjectid+"&pc_hash=<?php echo $_SESSION['pc_hash'];?>",
			dataType: "json",
			success:function(data){
				alert(data['msg']);
				window.location.reload();
			}
		})
	}
	function edit(id, name) {
		window.top.art.dialog({id:'edit'}).close();
		window.top.art.dialog({title:'<?php echo L('edit')?> '+name+' ',id:'edit',iframe:'?m=vote&c=vote&a=editoption&id='+id,width:'700',height:'300'}, function(){var d = window.top.art.dialog({id:'edit'}).data.iframe;var form = d.document.getElementById('dosubmit');form.click();return false;}, function(){window.top.art.dialog({id:'edit'}).close()});
	}

	function edits(id, name) {
		window.top.art.dialog({id:'edit'}).close();
		window.top.art.dialog({title:'<?php echo L('edit')?> '+name+' ',id:'edit',iframe:'?m=vote&c=vote&a=editoptionmoney&id='+id,width:'700',height:'200'}, function(){var d = window.top.art.dialog({id:'edit'}).data.iframe;var form = d.document.getElementById('dosubmit');form.click();return false;}, function(){window.top.art.dialog({id:'edit'}).close()});
	}
	setcookie('refersh_time', 0);
	function refersh_window() {
		var refersh_time = getcookie('refersh_time');
		if(refersh_time==1) {
			window.location.reload();
		}
	}
	setInterval("refersh_window()", 1500);
</script>
</body>
</html>